#!/usr/bin/env bash
# Updates symlinks to the .bats.template
set -euo pipefail
cd "$(dirname "$0")"

for tmpl in {.,}*.bats.template; do
    [[ -e "$tmpl" ]] || continue
    testCaseGroup=${tmpl%.bats.template}
    testCaseGroup=${testCaseGroup#.}
    rm -f "$testCaseGroup"-*.bats
    for testCase in "$testCaseGroup"-*; do
        [[ -d "$testCase" ]] || continue
        [[ ! -e "$testCase".skip ]] || continue
        ln -sfnv "$tmpl" "$testCase".bats
    done
done
